﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;

namespace SMSService
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class HelperService : System.Web.Services.WebService
    {
        ClassExecute.ClassExecute dt;
        string strcon = Configuration.CurrentConnectionString;
        string error = "";

        //[WebMethod]
        //public string InsertOrder(string phoneNumber, List<OrderOnline> lstParam)
        //{
        //    dt = new ClassExecute.ClassExecute();
        //    bool flag = true;
        //    for (int i = 0; i < lstParam.Count; i++)
        //    {
        //        int result = dt.ExecuteSQl_int(strcon, "TTr_DemoInsertOrderSMSMessage", System.Data.CommandType.StoredProcedure, ref error, new SqlParameter("@PhoneNo", phoneNumber),
        //            new SqlParameter("@Itemkey", lstParam[i].Itemkey), new SqlParameter("@shipqty", lstParam[i].Quantity), new SqlParameter("@SoTT", i + 1));
        //        if(result !=1)
        //        {
        //            flag = false;
        //            break;
        //        }
                
        //    }
        //    if (flag)
        //    {
        //        return "MadonHang";
        //    }
        //    else
        //    {
        //        return "NG";
        //    }
        //}

        [WebMethod]
        public void GetSmsMsg(string phoneNumber, string MsgSMS)
        {
            
            dt = new ClassExecute.ClassExecute();
            dt.ExecuteSQl_bool(strcon, System.Data.CommandType.StoredProcedure, "k_insertSMSToInbox", ref error,
                new SqlParameter("@Tel", phoneNumber),
                new SqlParameter("@Msg", MsgSMS));
            
        }

        [WebMethod]        
        public DataSet ResultSMS()
        {
            dt = new ClassExecute.ClassExecute();
            DataSet db = dt.Get_Data_DataSet(strcon, ref error, "k_getMessageToSend", System.Data.CommandType.StoredProcedure);

            return db;

        }

        //[WebMethod]
        //public string GetPV(string phoneNumber)
        //{
        //    //dt = new ClassExecute.ClassExecute();
        //    return "105.680.000";
        //}

        //[WebMethod]
        //public string GetGV(string phoneNumber)
        //{
        //    dt = new ClassExecute.ClassExecute();
        //    return "998.789.000";
        //}

        
    }
    public class OrderOnline
    {
        string _itemkey;
        string _quantity;
        public string Itemkey
        {
            get { return _itemkey; }
            set { _itemkey = value; }
        }
        public string Quantity
        {
            get { return _quantity; }
            set { _quantity = value; }
        }
    }
}